package com.semanticweb.webapp.ontology;

import org.springframework.util.StringUtils;

public enum CType {

    COUNTRY("country"), 
    CITY("city"), 
    MUSEUM("museum"), 
    INVENTARY_NUMBER("inventary", "number"), 
    NUMBER_IN_DOCUMENTATION("number", "in", "documentation"), 
    REPOSITORY("repository"), 
    NUMBER_OF_COPIES("number", "of", "copies"), 
    NEGATIVE_LABEL_AND_NUMBER("negative", "label", "and", "number"), 
    AUTHOR_ROLE("author", "role"), 
    WIDTH("width"), 
    HEIGHT("height"), 
    RADIUS("radius"), 
    WEIGHT("weight"), 
    THICKNESS("thickness"), 
    LENGTH("length"), 
    DESCRIPTION("description"), 
    SELLING("selling"), 
    NUMBER_IN_ENTRANCE_BOOK("number", "in", "entrance", "book"), 
    PRICE("price"), 
    CATEGORY("category"), 
    HISTORY("history"), 
    RESTORATION("restoration"), 
    LITERATURE("literature"), 
    DEPOT("depot"), 
    RECORD("record"), 
    REMARK("remark");

    public static final String ONT_TYPE = "type";
    
    private String value;
    private String uriSuffix;
    private String uri;

    private CType(final String... uriParts) {
        final StringBuffer valueBuffer = new StringBuffer();
        Boolean first = true;
        for (String s : uriParts) {
            if (first) {
                first = false;
            } else {
                s = StringUtils.capitalize(s);
            }
            valueBuffer.append(s);
        }
        this.value = valueBuffer.toString();
        
        this.uriSuffix = Ont.formatURIPart(uriParts);
        this.uriSuffix = Ont.formatURIPart(ONT_TYPE, this.uriSuffix);
        
        this.uri = Ont.formatURI(this.uriSuffix);
    }

    /**
     * Returns value of type, as stored in Ontology.
     * @return
     */
    public String getValue() {
        return this.value;
    }

    /**
     * Returns URI suffix for type.
     * @return
     */
    public String getUriSuffix() {
        return this.uriSuffix;
    }
    
    /**
     * Returns full URI for type.<br>
     * Name-space used for forming URI is {@link Ont#NS}.
     * 
     * @return
     */
    public String getURI() {
        return this.uri;
    }
    
    /**
     * Returns query URI for type.<br>
     * Name-space prefix used for forming URI is {@link Ont#QUERY_PREFIX}.
     * 
     * @return
     */
    public String queryValue() {
        return Ont.formatQueryURI(this.uriSuffix);
    }

}
